<!--
 * @Author         : yanyongyu
 * @Date           : 2022-09-16 16:42:19
 * @LastEditors    : yanyongyu
 * @LastEditTime   : 2022-10-22 03:44:29
 * @Description    : None
 * @GitHub         : https://github.com/yanyongyu
-->

{% from "icons/pr.html.jinja" import octicon_pr %}
{% from "icons/pr-closed.html.jinja" import octicon_pr_closed %}
{% from "icons/pr-draft.html.jinja" import octicon_pr_draft %}
{% from "icons/pr-merged.html.jinja" import octicon_pr_merged %}

{% macro pr_state(pull_request, class="") %}
<div class="{{ class }}">
  {% if pull_request.merged %}
  {% set state = "merged" %}
  {% elif pull_request.draft %}
  {% set state = "draft" %}
  {% elif pull_request.state == "closed" %}
  {% set state = "closed" %}
  {% else %}
  {% set state = "open" %}
  {% endif %}

  <span class="State State--{{ state }} mr-2">
    {% if pull_request.merged %}
    {{ octicon_pr_merged() }} Merged
    {% elif pull_request.draft %}
    {{ octicon_pr_draft() }} Draft
    {% elif pull_request.state == "closed" %}
    {{ octicon_pr_closed() }} Closed
    {% else %}
    {{ octicon_pr() }} Open
    {% endif %}
  </span>
</div>
{% endmacro %}
